﻿using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.ResourceManagement.ResourceProviders;
using UnityEngine.ResourceManagement.ResourceLocations;
using System;
using System.Text.RegularExpressions;

public class StartScene : MonoBehaviour
{
    [SerializeField] private Image sliderImg;
    [SerializeField] private Text progressTxT;

    AsyncOperationHandle<SceneInstance> handle;
    private void Awake()
    {
        AddressablesManager.Instance.InitializeAsync("http://localhost/AB");
    }
    private IEnumerator Start()
    {
        handle = Addressables.LoadSceneAsync("Assets/AssetBundle/Scenes/DemoScene.unity");
        float progress = 0;
        while (true)
        {
            progress = handle.GetDownloadStatus().Percent;
            progressTxT.text = progress + "%";
            sliderImg.fillAmount = progress;
            yield return null;
        }
    }
}
